package com.xiaoluyy.demo.config;

import com.xiaoluyy.common.codis.RedisService;
import com.xiaoluyy.common.codis.RedisServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * CodisClient configuration
 */


@Configuration
public class CodisClientConfig {

    @Value("${redis.url}")
    String address;

    @Value("${redis.maxActive}")
    Integer maxActive;

    @Value("${redis.maxIdle}")
    Integer maxIdle;

    @Bean(name = "redisService")
    public RedisService codisClient() {
        RedisServiceImpl redisService = new RedisServiceImpl();
        redisService.setRedisAddr(address);
        redisService.setMaxActive(maxActive);
        redisService.setMaxIdle(maxIdle);
        redisService.init();
        return redisService;
    }

}
